{% extends 'admin/base_admin.html' %}
{% block content %}
<a href="/admin/products/new" class="inline-block bg-emerald-600 text-white text-sm px-3 py-2 rounded">新建商品</a>
<table class="mt-4 w-full text-sm">
    <thead><tr class="text-left border-b"><th>主图</th><th>标题</th><th>分类</th><th>价格</th><th>上架</th><th></th></tr></thead>
    <tbody>
        {% for i in items %}
        <tr class="border-b">
            <td><img src="{{ i.cover_image|to_public }}" class="w-16 h-16 object-cover rounded" /></td>
            <td>{{ i.title }}</td>
            <td>{{ i.category.name if i.category }}</td>
            <td>{% if i.price %}{{ i.price|fmt_price(i.currency) }}{% endif %}</td>
            <td>{{ '✓' if i.is_published else '—' }}</td>
            <td class="text-right space-x-2">
                <a class="text-emerald-700" href="/admin/products/{{ i.id }}/edit">编辑</a>
                <form class="inline" action="/admin/products/{{ i.id }}/delete" method="post"><button class="text-rose-600">删除</button></form>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}